<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--引入jquery-->
<!--    <script src="webjars/jquery/3.3.1-2/jquery.min.js"></script>-->
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js"></script>
</head>
<body>

<shiro:guest>
    您好，请<a href="/login">登录</a>
</shiro:guest>
<shiro:authenticated>
    您好:<shiro:principal/>
</shiro:authenticated>

<table border="1">
</table>

<script>
    function fillTable(result){
        $("table").empty();
        for(let i = 0 ; i < result.length; i++){
            let goods = result[i];
            let $_tr = $("<tr></tr");
            let $_td1 = $("<td>" + goods.goodsId + "</td>");
            let $_td2 = $("<td>" + goods.goodsName + "</td>");
            let $_td3 = $("<td>" + goods.goodsType + "</td>");
            let $_td4 = $("<td>" + goods.goodsPrice + "</td>");
            let $_td5 = $("<td>" + goods.goodsCount + "</td>");
            let $_td6 = $("<td>" + goods.isDelete + "</td>");
            $_tr.append($_td1).append($_td2).append($_td3).append($_td4).append($_td5).append($_td6);
            $("table").append($_tr);
        }
    }
    function ajax(url){
        $.ajax({
            url:url,
            type:"post",
            async: true,
            dataType:"json",
            success:function(data){
                if (data.code == '200'){
                    fillTable(data.result);
                }
            }
        });
    }
    ajax("/goods/getAll/1/2");
</script>

</body>
</html>